<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/css/custom.form.css">
</head>
<body>
<div class="panel panel-default operation_case_dataScope" hidden>
    <div class="panel-heading title"></div>
    <div class="layui-card-body">
        <form class="layui-form " action="" lay-filter="deptInfo" style="width: 700px;margin-top: 10px">
            <input name="roleId" hidden/>
            <div class="layui-form-item">
                <label class="layui-form-label">数据范围</label>
                <div class="layui-input-block">
                    <input id="dataScope" name="dataScope" hidden/>
                    <select id="dataScopeS" name="dataScopeS" lay-filter="select-datascope">
                        <option value="">请选择</option>
                        <option value="0">省局</option>
                        <option value="1">市局</option>
                        <option value="2">县区局</option>

                    </select>
                </div>
            </div>
            <div id="choose-dept" hidden>
                <div class="layui-form-item" style="margin-left: 40px;">
                    <div class="layui-tree">
                        <div id="deptTree"></div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button type="submit" class="layui-btn" lay-submit="" lay-filter="submit_datascope">保存</button>
                    <button class="layui-btn layui-btn-primary" id="btn_cancel">返回</button>
                </div>
            </div>
        </form>
    </div>
</div>
<div class="case_table_div">
    <div id="searchParam">
        <div class="layui-form-item">
            <div class="layui-input-inline">
                <input type="text" id="nsrsbh" class="layui-input" autocomplete="off" placeholder="请输入纳税人识别号">
            </div>
<!--            <div class="layui-input-inline">-->
<!--                <input type="text" id="jcajbh" class="layui-input" autocomplete="off" placeholder="请输入稽查案件编号">-->
<!--            </div>-->
            <div class="layui-input-inline">
                <input type="text" id="nsrmc" class="layui-input" autocomplete="off" placeholder="请输入企业名称">
            </div>
            <div class="layui-input-inline">
                <input type="text" readonly class="layui-input" id="startTime" placeholder="入库日期起">
            </div>
            <div class="layui-input-inline">
                <input type="text" readonly class="layui-input" id="endTime" placeholder="入库日期止">
            </div>
            <div class="layui-input-inline layui-form">
                <select id="caseType">
                    <option value="0">请选择案件类型</option>
                    <option value="0">全部</option>
                    <option value="1">稽查</option>
                    <option value="2">自查</option>
                </select>
            </div>
            <div class="layui-input-inline layui-form">
                <select id="checkKeShi">
<!--                    <option value="">请选择检查科室</option>-->
<!--                    <option value="">全局</option>-->
<!--                    <option value="12101009141">检查一科</option>-->
<!--                    <option value="12101009142">检查二科</option>-->
<!--                    <option value="12101009143">检查三科</option>-->
<!--                    <option value="12101009144">检查四科</option>-->
<!--                    <option value="12101009145">检查五科</option>-->
<!--                    <option value="12101009130">综合选案科</option>-->
                </select>
            </div>
            <div class="layui-input-inline layui-form">
                <select id="area">
<!--                    <option value="">请选择所属区</option>-->
<!--                    <option value="">全局</option>-->
<!--                    <option value="12101060000">铁西</option>-->
<!--                    <option value="12101750000">经开</option>-->
<!--                    <option value="12101140000">于洪区</option>-->
<!--                    <option value="12101050000">皇姑区</option>-->
<!--                    <option value="12101220000">辽中区</option>-->
<!--                    <option value="12101810000">新民市</option>-->
                </select>
            </div>
            <div class="layui-input-inline ">
                <button class="layui-btn" onclick="search()" id="search">查询</button>
            </div>
        </div>

    </div>
    <table class="layui-hide" id="income_table" lay-filter="income_table"></table>
</div>
</body>
<script type="text/html" id="toolbar">
    <div class="layui-btn-container">
        <button class="layui-btn layui-btn-sm" lay-event="exportAllData" >导出全部数据</button>
    </div>
</script>
<script src="/layui/layui.all.js"></script>
<script src="/js/core.util.js"></script>
<script>
    //获取token
    var token = CoreUtil.getData("access_token");
    //地址栏转义token中的#号
    var tokenQuery = token.replace("#", "%23");
    var tableIns1;
    var table = layui.table;
    var form = layui.form;
    var layer = layui.layer;
    var $ = jQuery = layui.jquery;
    var laydate = layui.laydate;
    var tree = layui.tree;
    var startTime = null;
    var endTime = null;
    layui.config({
        base: '/'
    }).extend({
        eleTree: 'layui-ext/eleTree/eleTree'
    }).use(['table', 'laypage', 'layer', 'laydate', 'tree', 'eleTree'], function () {
        tableIns1 = table.render({
            elem: '#income_table'
            , contentType: 'application/json'
            , headers: {"authorization": token}
            ,where :{loadOrNOT:0}
            , url: '/attention/attentionInfome/incomelist' //数据接口
            ,title:"关注收入"
            , page:true
            , limits:[10]
            , method: 'POST', totalRow: true
            , parseData: function (res) { //将原始数据解析成 table 组件所规定的数据
                return {
                    "code": res.code, //解析接口状态
                    "msg": res.msg, //解析提示文本
                    "count": CoreUtil.isEmpty(res.data) ? 0 : res.data.total, //解析数据长度
                    "data": CoreUtil.isEmpty(res.data) ? null : res.data.records //解析数据列表
                }
            }
            , cols: [
                [
                    // {type: 'checkbox', fixed: 'left'},
                    {field: 'ajbh', title: '案件编号', width: 200, totalRowText: "汇总",templet:function(d) {
                            return d.ajbh + "\t";
                        }},
                    {field: 'nsrsbh', title: '纳税人识别号', width: 200,templet:function(d) {
                            return d.nsrsbh + "\t";
                        }},
                    {field: 'nsrmc', title: '纳税人名称', width: 200},
                    {field: 'jcks', title: '检查科室', width: 100},
                    {field: 'jcr', title: '检查人', width: 150},
                    {field: 'area', title: '所属区', width: 200},

                    {field: 'zsxm', title: '征收项目', width: 100},
                    {field: 'zspm', title: '征收品目', width: 100},
                    {field: 'sksx', title: '税款属性', width: 100},

                    {field: 'rksj', title: '入库时间', width: 100,templet:function(d) {
                            return d.rksj + "\t";
                        }},
                    {field: 'rkje', title: '入库金额', width: 200, totalRow: true},
                    {field: 'zyj', title: '中央级', width: 200},
                    {field: 'ssj', title: '省级', width: 200},
                    {field: 'dsj', title: '地市级', width: 200},
                    {field: 'qxj', title: '县区级', width: 200},
                    {field: 'xzj', title: '乡镇级', width: 200},
                ]
            ]
            , toolbar: '#toolbar'
        });


        table.on('toolbar(income_table)', function (obj) {
            layer.confirm('确定导出所有数据?', {icon: 3, title:'提示'}, function(index){
                var mapArr= { nsrmc: $("#nsrmc").val(),
                    startTime: $("#startTime").val(),
                    endTime: $("#endTime").val(),
                    caseType: $("#caseType").val(),
                    checkKeShi: $("#checkKeShi").val(),
                    area: $("#area").val(),
                    nsrsbh:$("#nsrsbh").val()
                    // ,
                    // jcajbh:$("#jcajbh").val()
                };
                CoreUtil.sendPost("/attention/attentionInfome/incomelistForExport", mapArr, function(res) {
                    if (res.code == '0') {
                        var data = res.data;
                        if (!CoreUtil.isEmpty(data)) {
                            //全部导出
                            table.exportFile(tableIns1.config.id, data, 'xls');
                            //导出时阻止页面刷新
                            $(".layui-form").submit(function (e) {
                                e.preventDefault();
                            })
                        } else {
                            layer.alert('未查询到需要导出的数据！', {icon: 2});
                        }
                    }
                });
                layer.close(index);
            });
        });
        laydate.render({
            elem: '#startTime'
            , type: 'date'
            , value: new Date()
            , done: function (value, date, endDate) {
                if (value != null && value != undefined && value != "") {
                    startTime = value;
                } else {
                    startTime = null;
                }
            }
        });
        laydate.render({
            elem: '#endTime'
            , type: 'date'
            , value: new Date()
            , done: function (value, date, endDate) {
                if (value != null && value != undefined && value != "") {
                    endTime = value;
                } else {
                    endTime = null;
                }
            }
        });

        //初始化检查科室查询条件
        CoreUtil.sendPost("/attention/gy/getcurrentswjgjcks", null, function(res) {
            let datas = res.data;
            let options = "<option value = ''>请选择检查科室</option><option value = ''>全局</option>";
            for (let i = 0; i < datas.length; i++) {
                options += '<option value="' + datas[i].swjgDm + '">' + datas[i].swjgjc + '</option>';
            }
            $('#checkKeShi').append(options);
            // 更新select渲染
            form.render('select');
        });

        //初始化区域
        CoreUtil.sendPost("/attention/gy/getallarea", null, function(res) {
            let datas = res.data;
            let options = "<option value = ''>请选择所属区</option><option value = ''>全局</option>";
            for (let i = 0; i < datas.length; i++) {
                options += '<option value="' + datas[i].swjgDm + '">' + datas[i].swjgmc + '</option>';
            }
            $('#area').append(options);
            // 更新select渲染
            form.render('select');
        });
    });

    //执行查询
    function search() {
        //这里以搜索为例
        tableIns1.reload({
            where: { //设定异步数据接口的额外参数，任意设
                nsrmc: $("#nsrmc").val(),
                startTime: $("#startTime").val(),
                endTime: $("#endTime").val(),
                caseType: $("#caseType").val(),
                checkKeShi: $("#checkKeShi").val(),
                area: $("#area").val(),
                loadOrNOT:"1",
                nsrsbh:$("#nsrsbh").val()
                // ,
                // jcajbh:$("#jcajbh").val()
            }
            , page: {
                curr: 1 //重新从第 1 页开始
            }
        });
    }
    function getCurrentDay(){
        var date = new Date();
        var year = date.getFullYear();
        var month = date.getMonth() + 1;
        var day = date.getDate();
        month = (month > 9) ? month : ("0" + month);
        day = (day < 10) ? ("0" + day) : day;
        var today = year + "-" + month + "-" + day;
        return today;
    }
</script>
</html>